package com.hd.appcommon.service.impl;

import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hd.appcommon.entity.Major;
import com.hd.appcommon.entity.OpenRecord;
import com.hd.appcommon.entity.vo.OpenRecordVo;
import com.hd.appcommon.mapper.MajorMapper;
import com.hd.appcommon.mapper.OpenRecordMapper;
import com.hd.appcommon.service.MajorService;
import com.hd.appcommon.service.OpenRecordService;
import com.hd.appcommon.utils.DateFormatUtil;
import com.hd.appcommon.utils.StringUtil;
import com.hd.appcommon.utils.TimeStampUtil;
import com.hd.hdxgddcommon.page.MyPage;
import com.hd.hdxgddcommon.utils.StringUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.management.Query;
import java.util.Date;

/**
 * @projectName: WebSocket
 * @package: com.Service.ServiceImpl
 * @className: OpenRecordServiceImpl
 * @author: 习
 * @description: TODO
 * @date: 2023/7/22 15:20
 * @version: 1.0
 */
@Slf4j
@Service
public class OpenRecordServiceImpl extends ServiceImpl<OpenRecordMapper, OpenRecord> implements OpenRecordService {
    @Autowired
    private OpenRecordMapper openRecordMapper;

    @Override
    public void saveMyOpenRecord(JSONObject jsonObject) {
        System.out.println("进入faceRecognition");
        String userId = jsonObject.getString("user_id");
        String device_id = jsonObject.getString("device_id");
        String timestamp = jsonObject.getString("timestamp");
        OpenRecord openRecord = new OpenRecord();
        String openTime = DateFormatUtil.timeStamp2Date(timestamp);
        openRecord.setUserId(userId);
        openRecord.setDeviceId(device_id);
        Date openDate = TimeStampUtil.StringToDate(openTime);
        openRecord.setOpenTime(openDate);
        this.save(openRecord);
    }

    @Override
    public IPage<OpenRecordVo> getOpenRecordPage(MyPage page, QueryWrapper queryWrapper) {
        return openRecordMapper.getOpenRecordPages(page,queryWrapper);
    }
}
